/*
 * @Des: 人员管理API
 * @Author: xu_lei
 * @Date: 2019-11-26 10:26:28
 * @LastEditor: xu_lei
 * @LastEditTime: 2021-09-24 14:54:57
 */

import request from '@/utils/request'

//获得所有用户分页
export function getUsers (data) {
  return request({
    url: '/sys-user/users/page',
    method: 'get',
    params: data,
  })
}

//新增用户
export function saveUser (data) {
  return request({
    url: '/sys-user/user',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
//更新用户
export function editUsers (data) {
  return request({
    url: '/sys-user/user',
    method: 'put',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

//根据搜索条件查询用户
export function searchUsers (data) {
  return request({
    url: '/sys-user/users/search',
    method: 'get',
    params: data
  })
}

//获取组织机构树
export function getOrg (portalId) {
  return request({
    url: '/sys-user/orgs/tree',
    method: 'get',
    params: {
      isAll: false,
      portalId: portalId
    }
  })
}
//获取岗位列表
export function getpost (portalId) {
  return request({
    url: '/sys-user/posts',
    method: 'get',
    params: {
      portalId: portalId
    }
  })
}

//更新用户所属门户
export function updatePortal (data) {
  return request({
    url: '/sys-user/portal',
    method: 'put',
    data: data
  })
}

//批量更新人员的组织机构信息
export function updateOrg (data) {
  return request({
    url: '/sys-user/org/users',
    method: 'put',
    data: data
  })
}

//导出人员
export function exportPeople (data) {
  return request({
    url: '/sys-user/users/export',
    method: 'post',
    data: data,
    responseType: 'blob'
  })
}